/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action.request;

import static com.opensymphony.xwork2.Action.SUCCESS;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import database.RequestDAO;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import model.Category;
import model.Request;
import model.Staff;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author Trang
 */
@Namespace("/Administration/Member")
public class ApproveRequestAction extends ActionSupport{
    private List<Request> requests = new ArrayList<Request>();
    private Staff approver;
    private String arler;
    RequestDAO requestDAO = new RequestDAO();

    public String getArler() {
        return arler;
    }

    public void setArler(String arler) {
        this.arler = arler;
    }

    
    public List<Request> getRequests() {
        return requests;
    }

    public Staff getApprover() {
        return approver;
    }

    public void setApprover(Staff approver) {
        this.approver = approver;
    }

    
    public void setRequests(List<Request> requests) {
        this.requests = requests;
    }
    
    @Action(
            value="viewRequest", results={
                @Result(name = "success", location ="/manageMember/w_viewRequest.jsp")
            })
    public String ViewReceiver()
    {
        Map session = ActionContext.getContext().getSession();
        approver = (Staff) session.get("staff");
        requests = requestDAO.getDirectorReceiveRequest(approver);
        if(requests.isEmpty())
        {
            arler = "You has no recieve request";
            System.out.println("AAA");
            addActionMessage("You has no recieve request");
                //.getUnprocessRequest(approver);
        }
        return SUCCESS;
    }
    @Action(
            value="viewDraff", results={
                @Result(name = "success", location ="/manageMember/w_viewRequest.jsp")
            })
    public String ViewDraff()
    {
        Map session = ActionContext.getContext().getSession();
        approver = (Staff) session.get("staff");
        System.out.println(approver);
        requests = requestDAO.getDraffRequest(approver);
        System.out.println(requests.size());
        if(requests.isEmpty())
        {
            arler = "You has no draff request";
        }
        return SUCCESS;
    }
}
